home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1996-02-22 | 3.6 KB | 106 lines | [TEXT/3PRM] |
- implementation module structure;
-
- import mac_types;
-
- :: Structure :== (!Handle,!Ptr);
-
- DereferenceHandle :: !Handle !Toolbox -> (!Ptr,!Toolbox);
- DereferenceHandle h tb = (DereferenceHandle1 h,tb);
-
- DereferenceHandle1 :: !Handle -> Ptr;
- DereferenceHandle1 h = code (h=D0)(pointer=D0){
- instruction 0x2040 || move.l d0,a0
- instruction 0x2010 || move.l (a0),d0
- };
-
- HandleToStructure :: !Handle -> Structure;
- HandleToStructure h = code (h=D0)(new_h=D1,pointer=D0){
- instruction 0x2200 || move.l d0,d1
- instruction 0x2040 || move.l d0,a0
- instruction 0x2010 || move.l (a0),d0
- };
-
- Append_long :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
- Append_long hp l tb = (AppendLong hp l,tb);
-
- AppendLong :: !Structure !Int -> Structure;
- AppendLong (h,p) l = code (h=D2, p=D1, l=D0)(new_h=D1, new_p=D0){
- instruction 0x2041 || move.l d1,a0
- instruction 0x20C0 || move.l d0,(a0)+
- instruction 0x2008 || move.l a0,d0
- instruction 0x2202 || move.l d2,d1
- };
-
- Append_word :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
- Append_word hp w tb = (AppendWord hp w,tb);
-
- AppendWord :: !Structure !Int -> Structure;
- AppendWord (h,p) w = code (h=D2, p=D1, w=D0) (new_h=D1, new_p=D0){
- instruction 0x2041 || move.l d1,a0
- instruction 0x30C0 || move.w d0,(a0)+
- instruction 0x2008 || move.l a0,d0
- instruction 0x2202 || move.l d2,d1
- };
-
- Append_byte :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
- Append_byte hp b tb = (AppendByte hp b,tb);
-
- AppendByte :: !Structure !Int -> Structure;
- AppendByte (h,p) b = code (h=D2, p=D1, b=D0) (new_h=D1, new_p=D0){
- instruction 0x2041 || move.l d1,a0
- instruction 0x10C0 || move.b d0,(a0)+
- instruction 0x2008 || move.l a0,d0
- instruction 0x2202 || move.l d2,d1
- };
-
- Append_zero_and_rect :: !Structure !Rect !Toolbox -> (!Structure,!Toolbox);
- Append_zero_and_rect hp rect tb = (Append_zero_and_rect1 hp rect,tb);
-
- Append_zero_and_rect1 :: !Structure !Rect -> Structure;
- Append_zero_and_rect1 (h,p) (left,top,right,bottom) = code (h=D5, p=D4, left=D3, top=D2, right=D1, bottom=D0)(new_h=D1, new_p=D0){
- instruction 0x2044 || move.l d4,a0
- instruction 0x4298 || clr.l (a0)+
- instruction 0x30C2 || move.w d2,(a0)+
- instruction 0x30C3 || move.w d3,(a0)+
- instruction 0x30C0 || move.w d0,(a0)+
- instruction 0x30C1 || move.w d1,(a0)+
- instruction 0x2008 || move.l a0,d0
- instruction 0x2205 || move.l d5,d1
- };
-
- Append_string_and_align :: !Structure !{#Char} !Toolbox -> (!Structure,!Toolbox);
- Append_string_and_align hp string tb = (Append_string_and_align1 hp string,tb);
-
- Append_string_and_align1 :: !Structure !{#Char} -> Structure;
- Append_string_and_align1 (h,p) string = code (h=D1, p=D0, string=A0) (new_h=D1, new_p=D0){
- instruction 0x5E88 || addq.l #7,a0
- instruction 0x2240 || move.l d0,a1
- instruction 0x7400 || moveq #0,d2
- instruction 0x1418 || move.b (a0)+,d2
- instruction 0x12C2 || move.b d2,(a1)+
- instruction 0x6002 || bra.s l2
- instruction 0x12D8 || l1: move.b (a0)+,(a1)+
- instruction 0x51CA
- instruction 0xFFFC || l2: dbra d2,l1
- instruction 0x2009 || move.l a1,d0
- instruction 0x5280 || addq.l #1,d0
- instruction 0x0880
- instruction 0x0000 || bclr #0,d0
- };
-
- Append_string :: !Structure !{#Char} !Toolbox -> (!Structure,!Toolbox);
- Append_string hp string tb = (AppendString hp string,tb);
-
- AppendString :: !Structure !{#Char} -> Structure;
- AppendString (h,p) string = code (h=D1, p=D0, string=A0) (new_h=D1, new_p=D0){
- instruction 0x5E88 || addq.l #7,a0
- instruction 0x2240 || move.l d0,a1
- instruction 0x7400 || moveq #0,d2
- instruction 0x1418 || move.b (a0)+,d2
- instruction 0x6002 || bra.s l2
- instruction 0x12D8 || l1: move.b (a0)+,(a1)+
- instruction 0x51CA
- instruction 0xFFFC || l2: dbra d2,l1
- instruction 0x2009 || move.l a1,d0
- };
-